home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / TurboTCP 1.0.1 / TurboTCP.source / CTCPApplication.cp < prev    next >
Text File  |  1993-12-10  |  2KB  |  91 lines

  1. /*
  2. ** CTCPApplication.cp
  3. **
  4. **    TurboTCP support library
  5. **    Application subclass
  6. **
  7. **    Copyright © 1993, FrostByte Design / Eric Scouten
  8. **
  9. */
  10.  
  11.  
  12. #include "CTCPApplication.h"
  13.  
  14. #include "CTCPDriver.h"
  15.  
  16.  
  17. //    —— startup/shutdown ——
  18.  
  19. /*______________________________________________________________________
  20. **
  21. ** ITCPApplication
  22. **
  23. **    Perform standard application initialization. Also opens MacTCP driver and resolver.
  24. **
  25. **        extraMasters (short):        how many calls to MoreMasters (I recommend
  26. **                                    a higher than usual value here…)
  27. **        aRainyDayFund (Size):        size of TCL’s “rainy day” fund
  28. **        aCriticalBalance (Size):        same as for CApplication::IApplication
  29. **        aToolboxBalance (Size):        same as for CApplication::IApplication
  30. **
  31. */
  32.  
  33. void CTCPApplication::ITCPApplication (short extraMasters, Size aRainyDayFund,
  34.                                 Size aCriticalBalance, Size aToolboxBalance)
  35.  
  36. {
  37.     gTCPDriver = NULL;
  38.     CApplication::IApplication(extraMasters, aRainyDayFund, aCriticalBalance,
  39.                         aToolboxBalance);
  40.     gTCPDriver = new (CTCPDriver);
  41.     gTCPDriver->ITCPDriver(TRUE);
  42.     cMaxSleepTime = 90;                    // don’t want to sleep for very long
  43.                                         // ALSO, must set the “Background Null Events”
  44.                                         //    checkbox under Set Project Type…
  45.                                         //    (SIZE flags)
  46. }
  47.  
  48.  
  49. /*______________________________________________________________________
  50. **
  51. ** Quit
  52. **
  53. **    Dispose of the TCP driver object.
  54. **
  55. **        return (Boolean):    TRUE if quit was confirmed by each window
  56. */
  57.  
  58. Boolean CTCPApplication::Quit (void)
  59.  
  60. {
  61.     Boolean    reallyQuitting;
  62.     
  63.     reallyQuitting = CApplication::Quit();
  64.     if (reallyQuitting) {
  65.         if (gTCPDriver)                            // can’t use ForgetObject, since we need the
  66.             gTCPDriver->Dispose();                //     reference to gTCPDriver to be valid during Dispose
  67.         gTCPDriver = NULL;
  68.     }
  69.     
  70.     return (reallyQuitting);
  71. }
  72.  
  73.  
  74. //    —— foreground/background event trapping ——
  75.  
  76. /*______________________________________________________________________
  77. **
  78. ** Process1Event
  79. **
  80. **    Here we tap into the event loop to process TCP completions and notifications, now freed
  81. **    from interrupt-level constraints on memory management.
  82. **
  83. */
  84.  
  85. void CTCPApplication::Process1Event (void)
  86.  
  87. {
  88.     gTCPDriver->ProcessNetEvents();
  89.     CApplication::Process1Event();
  90. }
  91.